var clssName = "hover-sub";

//event when load window
window.onload =function(){
    var elms = document.getElementsByClassName('dropdown-menu-sub');
    for (var i = 0; i < elms.length; i++){
    	var ulparent = elms[i];
    	ulparent.onmouseover = function(){
    		this.className = this.className + " " + clssName;
    	}
    	
    	ulparent.onmouseout = function(){
    		removeClassName(this,clssName);
    	}
    }

}


//scroll window
window.onscroll = function (e) {
	if(window.pageYOffset != 0){
		$("#scrolltop").fadeIn(600, "linear", function complete(){});
	
	}else{
		$("#scrolltop").fadeOut(600, "linear", function complete(){});
	}
}

function scrolltop(){	
	  $('html, body').animate({scrollTop:0}, '2000');
}

function addClassName(elem, name){
    var remClass = elem.className;
    var re = new RegExp('(^| )' + name + '( |$)');
    remClass = remClass.replace(re, '$1');
    remClass = remClass.replace(/ $/, '');
    elem.className = remClass;
}

function removeClassName(elem, name){
    var remClass = elem.className;
    var re = new RegExp('(^| )' + name + '( |$)');
    remClass = remClass.replace(re, '$1');
    remClass = remClass.replace(/ $/, '');
    elem.className = remClass;
}